package com.yonyou.crm.cum.customer.dynamic;

import java.util.Date;

import com.yonyou.crm.cum.customer.entity.CustomerVO;
import com.yonyou.crm.sys.dynamic.builder.DynamicContentBuilder;
import com.yonyou.crm.sys.dynamic.builder.Field;
import com.yonyou.crm.sys.dynamic.builder.Link;
import com.yonyou.crm.sys.dynamic.entity.DynamicVO;
import com.yonyou.crm.sys.dynamic.impl.DynamicServiceImpl;
import com.yonyou.crm.sys.modules.entity.MtObjTypeEnum;
import com.yonyou.crm.sys.user.entity.UserVO;

public class DymCumIdentifyCancel {
	DynamicServiceImpl dynamicService;
	
	UserVO user ;
	
	CustomerVO vo;
	
	Long[] relUserArr;
	public DymCumIdentifyCancel(DynamicServiceImpl dynamicService,UserVO user,CustomerVO vo,Long[] relUserArr) {
		this.dynamicService = dynamicService;
		this.user = user;
		this.vo = vo;
		this.relUserArr = relUserArr;
	}
	
	public void execute() {
		
		//添加动态逻辑
		//xxx对客户xxx取消了企业核实
		DynamicVO dym = new DynamicVO();
		dym.setCreatedTime(new Date());
		dym.setObjId(vo.getId());
		dym.setObjType(MtObjTypeEnum.CUSTOMER.getValue());//客户
		dym.setOwnerId(user.getId());
		dym.setTenantId(user.getTenantId());
		dym.setOrgId(user.getOrgId());
		DynamicContentBuilder builder = new DynamicContentBuilder();
		Field f1 = new Field("",new Link(user.getName(),"USER",user.getId(),"",""));
		builder.append(f1);
		builder.append("对");
		Field f2 = new Field("客户",new Link(vo.getName(),"CUSTOMER",vo.getId(),"",""));
		builder.append(f2);
		builder.append("取消了企业核实");
		dym.setContent(builder.toJSON());
		dynamicService.insert(dym, relUserArr);
	}
}
